package com.sheng.project.study.spring.demo01;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author liusheng
 * @date 2023/07/06
 */
@Configuration
public class ConfigBean2 {
    @Bean
    public ServiceA serviceA() {
        System.out.println("调用 serviceA() 方法");
        return new ServiceA();
    }

    @Bean
    ServiceB serviceB1() {
        System.out.println("调用 serviceB1() 方法");
        ServiceA serviceA = this.serviceA();
        return new ServiceB(serviceA);
    }

    @Bean
    ServiceB serviceB2() {
        System.out.println("调用 serviceB2() 方法");
        ServiceA serviceA = this.serviceA();
        return new ServiceB(serviceA);
    }
}
